Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

energy-management-app: Split WH and EVSE into 2 endpoints #36201

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

soares-sergio
Copy link
Contributor

@soares-sergio soares-sergio commented Oct 22, 2024

This PR refactors the energy-management-app into 2 separate endpoints
(one for EVSE and another for WaterHeater).

This is the first step in making this app spec-conformant.

TC_DeviceBasicComposition.py failed on this app before this PR and now passes.

Changes:

  • Split Water Heater and EVSE into two separate endpoints (1 and 2).
    Updated zap and code.
  • Dinamically disable unused endpoint at runtime. Based on the app choice
    (command line argument on linux or #define in ESP32 or SIlabs), initialize
    the clusters in the correct endpoint and disable the other endpoint.
    For example, for Water Heater, initialize clusters on endpoint 2 and
    disable endpoint 1 (EVSE).
  • Refactor/move the cluster init code related to ElectricalSensor (PowerTopology, EPM and EEM) and DEM from inside EVSE
    into EnergyManagementAppMain.h/.cpp so it can be easier to reuse by both WaterHeater and EVSE.

Test performed:

  1. Check basic composition for EVSE:
scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application evse --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"'
  1. Check basic composition for WaterHeater:
scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application water-heater --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"'
  1. Check app against TC_EEVSE_2_6.py:
rm -f evse.bin; ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --enable-key 000102030405060708090a0b0c0d0e0f --KVS evse.bin --featureSet 0x3d

python src/python_testing/TC_EEVSE_2_6.py --endpoint 1 -m on-network -n 1234 -p 20202021 -d 3840 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f
  1. Verified it builds for esp32, silabs and linux.
  2. Verified all-clusters-app builds

This PR adds the missing Water Heater device to matter-devices.xml.

The description was generated using the Alchemy tool
(https://github.com/project-chip/alchemy) with the following command:

`alchemy zap --attribute="in-progress"  --sdkRoot=./connectedhomeip/
--specRoot=./connectedhomeip-spec/
./connectedhomeip-spec/src/device_types/WaterHeater.adoc`

I manually fixed the device nae from `Matter Water Heater` to `Water
Heater`.
This PR refactors the energy-management-app into 2 separate endpoints
(one for EVSE and another for WaterHeater).

This is the first step in making this app spec-conformant.

`TC_DeviceBasicComposition.py` failed on this app before this PR and now passes.

Changes:
* Split Water Heater and EVSE into two separate endpoints (1 and 2).
  Updated zap and code.
* Dinamically disable unused endpoint at runtime. Based on the app choice
  (command line argument on linux or #define in ESP32 or SIlabs), initialize
  the clusters in the correct endpoint and disable the other endpoint.
  For example, for Water Heater, initialize clusters on endpoint 2 and
  disable endpoint 1 (EVSE).
* Refactor/move the init code related to ElectricalSensor (PowerTopology, EPM and EEM) from inside EVSE
  into ElectricalSensorInit.h/.cpp so they can be easier to reuse by both WaterHeater and EVSE.
* Refactor/move DEM cluster init code into its own file so it can be
  better reused outside EVSE.

Test performed:
1. Check basic composition for EVSE:
```
scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application evse --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"'
```

2. Check basic composition for WaterHeater:
```
scripts/run_in_python_env.sh out/python_env './scripts/tests/run_python_test.py --app ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --app-args "--application water-heater --trace-to json:log" --script src/python_testing/TC_DeviceBasicComposition.py --script-args "--qr-code MT:-24J0AFN00KA0648G00"'
```

3. Check app against `TC_EEVSE_2_6.py`:
```
rm -f evse.bin; ./out/linux-x64-energy-management-no-ble/chip-energy-management-app --enable-key 000102030405060708090a0b0c0d0e0f --KVS evse.bin --featureSet 0x3d

python src/python_testing/TC_EEVSE_2_6.py --endpoint 1 -m on-network -n 1234 -p 20202021 -d 3840 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f
```
@soares-sergio soares-sergio requested review from a team as code owners October 22, 2024 20:04
Copy link

semanticdiff-com bot commented Oct 22, 2024

Review changes with  SemanticDiff

Copy link

github-actions bot commented Oct 22, 2024

PR #36201: Size comparison from 0b93b0d to ea06d89

Full report (7 builds for cc32xx, qpg, stm32, tizen)
platform target config section 0b93b0d ea06d89 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617162 617162 0 0.0
RAM 205908 205908 0 0.0
lock CC3235SF_LAUNCHXL FLASH 657210 657210 0 0.0
RAM 206060 206060 0 0.0
qpg lighting-app qpg6105+debug FLASH 660600 660600 0 0.0
RAM 105396 105396 0 0.0
lock-app qpg6105+debug FLASH 618612 618612 0 0.0
RAM 99864 99864 0 0.0
stm32 light STM32WB5MM-DK FLASH 481936 481936 0 0.0
RAM 144844 144844 0 0.0
tizen all-clusters-app arm unknown 4912 4912 0 0.0
FLASH 1729756 1729756 0 0.0
RAM 90108 90108 0 0.0
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18237078 18237102 24 0.0
RAM 7945732 7945732 0 0.0

Copy link

github-actions bot commented Oct 22, 2024

PR #36201: Size comparison from 0b93b0d to f05afff

Full report (14 builds for cc13x4_26x4, cc32xx, nrfconnect, qpg, stm32, tizen)
platform target config section 0b93b0d f05afff change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 829564 829564 0 0.0
RAM 123452 123452 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 814872 814872 0 0.0
RAM 125332 125332 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 761460 761460 0 0.0
RAM 113824 113824 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 745704 745704 0 0.0
RAM 114016 114016 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617162 617162 0 0.0
RAM 205908 205908 0 0.0
lock CC3235SF_LAUNCHXL FLASH 657210 657210 0 0.0
RAM 206060 206060 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915528 915528 0 0.0
RAM 143357 143357 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 885992 885992 0 0.0
RAM 141496 141496 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848936 848936 0 0.0
RAM 142265 142265 0 0.0
qpg lighting-app qpg6105+debug FLASH 660600 660600 0 0.0
RAM 105396 105396 0 0.0
lock-app qpg6105+debug FLASH 618612 618612 0 0.0
RAM 99864 99864 0 0.0
stm32 light STM32WB5MM-DK FLASH 481936 481936 0 0.0
RAM 144844 144844 0 0.0
tizen all-clusters-app arm unknown 4912 4912 0 0.0
FLASH 1729756 1729756 0 0.0
RAM 90108 90108 0 0.0
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18237078 18237102 24 0.0
RAM 7945732 7945732 0 0.0

@mergify mergify bot added the conflict label Oct 24, 2024
@mergify mergify bot removed the conflict label Oct 24, 2024
Copy link

github-actions bot commented Oct 24, 2024

PR #36201: Size comparison from 692983e to 9dee3de

Full report (49 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 692983e 9dee3de change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1350120 1350120 0 0.0
RAM 104120 104120 0 0.0
bl702 lighting-app bl702+eth FLASH 647856 647856 0 0.0
RAM 25233 25233 0 0.0
bl702+wifi FLASH 825164 825164 0 0.0
RAM 13965 13965 0 0.0
bl706+mfd+rpc+littlefs FLASH 1054154 1054154 0 0.0
RAM 23821 23821 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 974938 974938 0 0.0
RAM 16468 16468 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 836660 836660 0 0.0
RAM 123676 123676 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 821960 821960 0 0.0
RAM 125556 125556 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 768532 768532 0 0.0
RAM 114048 114048 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 752792 752792 0 0.0
RAM 114240 114240 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 627466 627466 0 0.0
RAM 206132 206132 0 0.0
lock CC3235SF_LAUNCHXL FLASH 667458 667458 0 0.0
RAM 206284 206284 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 678621 678621 0 0.0
RAM 78692 78692 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 698465 698465 0 0.0
RAM 81324 81324 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 698465 698465 0 0.0
RAM 81324 81324 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 655401 655401 0 0.0
RAM 73760 73760 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 615037 615037 0 0.0
RAM 71644 71644 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 634665 634665 0 0.0
RAM 74196 74196 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 634665 634665 0 0.0
RAM 74196 74196 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 634309 634309 0 0.0
RAM 74692 74692 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 654017 654017 0 0.0
RAM 77244 77244 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 654017 654017 0 0.0
RAM 77244 77244 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 609669 609669 0 0.0
RAM 68780 68780 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 629521 629521 0 0.0
RAM 71412 71412 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 629521 629521 0 0.0
RAM 71412 71412 0 0.0
efr32 lock-app BRD4187C FLASH 925644 925644 0 0.0
RAM 159920 159920 0 0.0
BRD4338a FLASH 742216 742216 0 0.0
RAM 232580 232580 0 0.0
window-app BRD4187C FLASH 1018568 1018568 0 0.0
RAM 128264 128264 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915564 915564 0 0.0
RAM 143357 143357 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 886032 886032 0 0.0
RAM 141496 141496 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848972 848972 0 0.0
RAM 142265 142265 0 0.0
nxp contact k32w0+release FLASH 582424 582424 0 0.0
RAM 71092 71092 0 0.0
mcxw71+release FLASH 596896 596896 0 0.0
RAM 63184 63184 0 0.0
light k32w0+release FLASH 619044 619044 0 0.0
RAM 70556 70556 0 0.0
k32w1+release FLASH 683144 683144 0 0.0
RAM 48816 48816 0 0.0
lock mcxw71+release FLASH 746704 746704 0 0.0
RAM 67340 67340 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1647668 1647668 0 0.0
RAM 212408 212408 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553740 1553740 0 0.0
RAM 209208 209208 0 0.0
light cy8ckit_062s2_43012 FLASH 1468004 1468004 0 0.0
RAM 201200 201200 0 0.0
lock cy8ckit_062s2_43012 FLASH 1464964 1464964 0 0.0
RAM 225560 225560 0 0.0
qpg lighting-app qpg6105+debug FLASH 660536 660536 0 0.0
RAM 105420 105420 0 0.0
lock-app qpg6105+debug FLASH 618628 618628 0 0.0
RAM 99880 99880 0 0.0
stm32 light STM32WB5MM-DK FLASH 481920 481920 0 0.0
RAM 144844 144844 0 0.0
telink bridge-app tlsr9258a FLASH 681136 681136 0 0.0
RAM 91304 91304 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 620782 620782 0 0.0
RAM 50600 50600 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 708762 708762 0 0.0
RAM 73940 73940 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625736 625736 0 0.0
RAM 144468 144468 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 811746 811746 0 0.0
RAM 99100 99100 0 0.0
tizen all-clusters-app arm unknown 4912 4912 0 0.0
FLASH 1729952 1729952 0 0.0
RAM 90108 90108 0 0.0
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18237510 18237510 0 0.0
RAM 7945192 7945192 0 0.0

@soares-sergio
Copy link
Contributor Author

@jamesharrow @PeterC1965 from the git history, looks like you both are familiar with this app. Would you mind taking a look at this PR? I've only tested these changes on linux. Thanks!

@lboue
Copy link
Contributor

lboue commented Oct 29, 2024

@soares-sergio I notice that the values returned are always zero. Is there an option to activate to correct this?

./chip-tool waterheatermanagement read tank-volume 1 2
[1730241520.721] [33588:33590] [TOO] Endpoint: 2 Cluster: 0x0000_0094 Attribute 0x0000_0002 DataVersion: 2890564126
[1730241520.721] [33588:33590] [TOO]   TankVolume: 0

./chip-tool waterheatermanagement read tank-percentage 1 2
[1730241866.744] [33693:33695] [TOO] Endpoint: 2 Cluster: 0x0000_0094 Attribute 0x0000_0004 DataVersion: 2890564126
[1730241866.744] [33693:33695] [TOO]   TankPercentage: 0

./chip-tool waterheatermanagement read boost-state 1 2
[1730241738.703] [33659:33661] [TOO] Endpoint: 2 Cluster: 0x0000_0094 Attribute 0x0000_0005 DataVersion: 2890564126
[1730241738.705] [33659:33661] [TOO]   BoostState: 0

Steps (water-heater)

cd ~/connectedhomeip/examples/energy-management-app/linux
gn gen out/debug
ninja -C out/debug -j2
./out/debug/chip-energy-management-app --application water-heater --trace-to json:log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants